package cuongnh.project.japanesediary.vocabulary.ui.editor.vocabulary.page.related;

import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.ui.forms.IManagedForm;
import org.eclipse.ui.forms.editor.FormEditor;
import org.eclipse.ui.forms.editor.FormPage;
import org.eclipse.ui.forms.widgets.FormToolkit;
import org.eclipse.ui.forms.widgets.ScrolledForm;
import org.eclipse.ui.forms.widgets.Section;

import cuongnh.project.japanesediary.vocabulary.common.CommonServices;
import cuongnh.project.japanesediary.vocabulary.model.Vocabulary;
import cuongnh.project.japanesediary.vocabulary.ui.editor.vocabulary.page.related.section.AntonymVocabulariesSection;
import cuongnh.project.japanesediary.vocabulary.ui.editor.vocabulary.page.related.section.HomophoneVocabulariesSection;
import cuongnh.project.japanesediary.vocabulary.ui.editor.vocabulary.page.related.section.RelatedVocabulariesSection;
import cuongnh.project.japanesediary.vocabulary.ui.editor.vocabulary.page.related.section.SynonymVocabulariesSection;

public class RelatedVocabularyPage extends FormPage {
	private Vocabulary vocabulary;
	private CommonServices commonServices;

	public RelatedVocabularyPage(FormEditor editor, Vocabulary vocabulary,
			CommonServices commonServices, String id, String title) {
		super(editor, id, title);
		this.vocabulary = vocabulary;
		this.commonServices = commonServices;
	}

	/**
	 * Create contents of the form.
	 * 
	 * @param managedForm
	 */
	@Override
	protected void createFormContent(IManagedForm managedForm) {
		FormToolkit toolkit = managedForm.getToolkit();
		ScrolledForm form = managedForm.getForm();
		//form.setText("Empty FormPage");
		Composite body = form.getBody();
		toolkit.decorateFormHeading(form.getForm());
		toolkit.paintBordersFor(body);
		managedForm.getForm().getBody().setLayout(new GridLayout(2, true));

		RelatedVocabulariesSection relatedVocabulariesSection = new RelatedVocabulariesSection(
				body, toolkit, Section.EXPANDED | Section.TITLE_BAR,
				vocabulary, commonServices);
		relatedVocabulariesSection.getSection().setLayoutData(
				new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));

		HomophoneVocabulariesSection homophoneVocabulariesSection = new HomophoneVocabulariesSection(
				body, toolkit, Section.EXPANDED | Section.TITLE_BAR,
				vocabulary, commonServices);
		homophoneVocabulariesSection.getSection().setLayoutData(
				new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));

		SynonymVocabulariesSection synonymVocabulariesSection = new SynonymVocabulariesSection(
				body, toolkit, Section.EXPANDED | Section.TITLE_BAR,
				vocabulary, commonServices);
		synonymVocabulariesSection.getSection().setLayoutData(
				new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));

		AntonymVocabulariesSection antonymVocabulariesSection = new AntonymVocabulariesSection(
				body, toolkit, Section.EXPANDED | Section.TITLE_BAR,
				vocabulary, commonServices);
		antonymVocabulariesSection.getSection().setLayoutData(
				new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));

	}
}
